/** 
 * @func  验证选项的类型  配置参数合法性
 * @params target:属性
 * @params targetName:属性名称
 * @params expectType:字段类型
*/
export function validateOption(target: any, targetName: string, expectType: string): any {
    if (!target) return false;
    if (getTypeogAny(target) === expectType) return true;
    console.error(`you-see: ${targetName}期望传入${expectType}类型，目前是${getTypeogAny(target)}类型`);
}
// 获取类型
function getTypeogAny(target) {
    return Object.prototype.toString.call(target).slice(8, -1).toLowerCase()
}

function isType(type: any) {
    return function (value: any): boolean {
        return Object.prototype.toString.call(value) === `[object ${type}]`;
    };
}
/**
 * 检测变量类型
 * @param type
 */
export const variableTypeDetection = {
    isNumber: isType('Number'),
    isString: isType('String'),
    isBoolean: isType('Boolean'),
    isNull: isType('Null'),
    isUndefined: isType('Undefined'),
    isSymbol: isType('Symbol'),
    isFunction: isType('Function'),
    isObject: isType('Object'),
    isArray: isType('Array'),
    isProcess: isType('process'),
    isWindow: isType('Window'),
};
// 判断环境
export const isBrowserEnv = variableTypeDetection.isWindow(
    typeof window !== 'undefined' ? window : 0
);